﻿using System.Collections.Generic;
using System.Runtime.Serialization;

namespace Sharp.WebBooter
{
    [DataContract]
    public class DataTableParameter
    {
        public DataTableParameter()
        {

        }

        /// <summary>
        /// DataTable请求服务器端次数
        /// </summary> 
        [DataMember(Name = "draw")]
        public string Draw { get; set; }

        /// <summary>
        /// 每页显示的数量
        /// </summary>
        [DataMember(Name = "length")]
        public int Length { get; set; }

        /// <summary>
        /// 分页时每页跨度数量
        /// </summary>
        [DataMember(Name = "start")]
        public int Start { get; set; }

        /// <summary>
        /// 列
        /// </summary>
        [DataMember(Name = "columns")]
        public List<Column> Columns { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        [DataMember(Name = "order")]
        public List<OrderInfo> Order { get; set; }
        /// <summary>
        /// 额外post过来的数据
        /// </summary>
        [DataMember(Name = "data")]
        public dynamic PostData { get; set; }

        [DataContract]
        public class Column
        {
            [DataMember(Name = "data")]
            public string Data { get; set; }

            [DataMember(Name = "name")]
            public string Name { get; set; }

            [DataMember(Name = "orderable")]
            public bool Orderable { get; set; }

            [DataMember(Name = "searchable")]
            public bool Searchable { get; set; }

            [DataMember(Name = "search")]
            public Search SearchInfo { get; set; }

            public class Search
            {
                [DataMember(Name = "regex")]
                public bool Regex { get; set; }

                [DataMember(Name = "value")]
                public string Value { get; set; }
            }
        }
        [DataContract(Name = "order")]
        public class OrderInfo
        {
            [DataMember(Name = "column")]
            public int Column { get; set; }
            [DataMember(Name = "dir")]
            public string Dir { get; set; }
        }
    }

    [DataContract]
    public class ReturnedData
    {
        [DataMember(Name = "draw")]
        public int Draw { get; set; }
        [DataMember(Name = "recordsTotal")]
        public int RecordsTotal { get; set; }
        [DataMember(Name = "recordsFiltered")]
        public int RecordsFiltered { get; set; }
        [DataMember(Name = "data")]
        public object Data { get; set; }
        [DataMember(Name = "error")]
        public string Error { get; set; }
    }
}
